<template>
  <basic-container>
    <avue-crud
      :option="option"
      :search.sync="search"
      :table-loading="loading"
      :data="data"
      :page.sync="page"
      :permission="permissionList"
      :before-open="beforeOpen"
      v-model="form"
      ref="crud"
      @search-change="searchChange"
      @search-reset="searchReset"
      @selection-change="selectionChange"
      @current-change="currentChange"
      @size-change="sizeChange"
      @refresh-change="refreshChange"
      @sort-change="sortChange"
      @on-load="onLoad"
    >
    <!-- 
      @row-update="rowUpdate"               编辑数据后确定触发该事件
      @row-save="rowSave"                   新增数据后点击确定触发该事件
      @row-del="rowDel"                     行数据删除时触发该事件
      @search-change="searchChange"         击搜索后触发该事件(由于page分页信息和search搜索信息是sync修饰符，可以直接通过this.page和this.search拿到)
      @search-reset="searchReset"           清空搜索回调方法
      @selection-change="selectionChange"   当选择项发生变化时会触发该事件
      @current-change="currentChange"       分页页码改变时会触发
      @size-change="sizeChange"             pageSize改变时会触发 
      @refresh-change="refreshChange"       点击刷新按钮触发该事件(由于page分页信息和search搜索信息是sync修饰符，可以直接通过this.page和this.search拿到)
      @sort-change="sortChange"             当表格的排序条件发生变化的时候会触发该事件
      @on-load="onLoad"                   
     -->
    </avue-crud>
  </basic-container>
</template>

<script>
import { getList } from "@/api/rb-core/oemWithdrawal/oem_withdrawal";
import { mapGetters } from "vuex";
// import { getToken } from "@/util/auth";
export default {
  data() {
    return {
      form: {},
      query: {},
      search: {},
      loading: true,
      takeOutLoading:false,
      page: {
        pageSize: 10,
        currentPage: 1,
        total: 0,
      },
      selectionList: [],
      option: {
        height: "auto",
        calcHeight: 30,
        tip: false,
        border: true,
        index: true,
        addBtn:false,
        viewBtn: true,
        selection: true,
        searchMenuSpan: 24,
        columnBtn: false,
        editBtn:false,// 编辑按钮
        delBtn:false,// 删除
        // menuWidth:150,       //操作栏宽度
        // labelWidth:120,      //弹出表单的标题的统一宽度
        searchLabelWidth: 120, //搜索框标题宽度
        column: [
          {
            label: "开户名称",//
            prop: "robBankName",
            type: "input",
            sortable: true,
            search: true,
            rules: [
              {
                required: true,
                message: "请输入开户名称",
                trigger: "blur",
              },
            ],
            overHidden: true
          },
          {
            label: "开户行",
            prop: "robBank",//
            type: "input",
            search: true,
            rules: [
              {
                required: true,
                message: "请输入开户行",
                trigger: "blur",
              },
            ],
            overHidden: true
          },
          {
            label: "账户类型",//
            prop: "accountType",
            type: "select",
            sortable: true,
            search: true,
            rules: [
              {
                required: true,
                message: "请选择账户类型",
                trigger: "blur",
              },
            ],
            dataType: 'number',
            dicUrl: "/api/blade-system/dict/dictionary?code=account_type",
            props: {
              label: "dictValue",
              value: "dictKey"
            },
            overHidden: true
          },
          {
            label: "转账类型",//
            prop: "forwardType",
            type: "select",
            search: true,
            rules: [
              {
                required: true,
                message: "请选择转账类型",
                trigger: "blur",
              },
            ],
            dataType: 'number',
            dicUrl: "/api/blade-system/dict/dictionary?code=forward_type",
            props: {
              label: "dictValue",
              value: "dictKey"
            },
            overHidden: true
          },
          {
            label: "提现金额",
            prop: "rowMoney",//
            type: "input",
            search: true,
            rules: [
              {
                required: true,
                message: "请输入提现金额",
                trigger: "blur",
              },
            ],
            overHidden: true,
          },
          {
            label: "提现状态",//
            prop: "rowStatus",
            type:'select',
            search: true,
            sortable: true,
            rules: [
              {
                required: true,
                message: "请选择提现状态",
                trigger: "blur",
              },
            ],
            dataType: 'number',
            dicUrl: "/api/blade-system/dict/dictionary?code=row_status",
            props: {
              label: "dictValue",
              value: "dictKey"
            },
            overHidden: true
          },
          {
            label: "提现日期",//
            search: false,
            sortable: true,
            prop: "withdrawDate",
            type: "datetime",
            defaultTime:['00:00:00', '23:59:59'],
            format:'yyyy-MM-dd hh:mm:ss',
            valueFormat:'yyyy-MM-dd hh:mm:ss',
            rules: [
              {
                required: true,
                message: "请输入提现日期",
                trigger: "blur",
              },
            ],
            overHidden: true
          },
          {
            label: "审核日期",//
            prop: "adminDate",
            type: "datetime",
            defaultTime:['00:00:00', '23:59:59'],
            format:'yyyy-MM-dd hh:mm:ss',
            valueFormat:'yyyy-MM-dd hh:mm:ss',
            search: false,
            sortable: true,
            rules: [
              {
                required: true,
                message: "请选择审核日期",
                trigger: "blur",
              },
            ],
            overHidden: true
          },
          {
            label: "到账日期",//
            prop: "notifyDate",
            type: "datetime",
            defaultTime:['00:00:00', '23:59:59'],
            format:'yyyy-MM-dd hh:mm:ss',
            valueFormat:'yyyy-MM-dd hh:mm:ss',
            search: false,
            sortable: true,
            rules: [
              {
                required: true,
                message: "请选择到账日期",
                trigger: "blur",
              },
            ],
            overHidden: true
          },
          {
            search: true,
            label: "提现日期时间段",
            type: 'datetimerange',
            prop:'withdrawDateTime',
            searchRange: true,
            defaultTime:['00:00:00', '23:59:59'],
            format:'yyyy-MM-dd HH:mm:ss',
            valueFormat:'yyyy-MM-dd HH:mm:ss',
            startPlaceholder: '提现日期时间开始时间',
            endPlaceholder: '提现日期时间结束时间',
            hide:true,
            display:false,
            overHidden: true
          },
          {
            search: true,
            label: "审核日期时间段",
            type: 'datetimerange',
            prop:'adminDateTime',
            searchRange: true,
            defaultTime:['00:00:00', '23:59:59'],
            format:'yyyy-MM-dd HH:mm:ss',
            valueFormat:'yyyy-MM-dd HH:mm:ss',
            startPlaceholder: '审核日期时间开始时间',
            endPlaceholder: '审核日期时间结束时间',
            hide:true,
            display:false,
            overHidden: true
          },
          {
            search: true,
            label: "到账日期时间段",
            type: 'datetimerange',
            prop:'notifyDateTime',
            searchRange: true,
            defaultTime:['00:00:00', '23:59:59'],
            format:'yyyy-MM-dd HH:mm:ss',
            valueFormat:'yyyy-MM-dd HH:mm:ss',
            startPlaceholder: '到账日期时间开始时间',
            endPlaceholder: '到账日期时间结束时间',
            hide:true,
            display:false,
            overHidden: true
          },
          {
            label: "审核意见",//
            prop: "robReason",
            type: "textarea",
            search: false,
            sortable: true,
            overHidden: true
          }
        ],
      },
      data: [],
    };
  },
  computed: {
    ...mapGetters(["permission"]),
    permissionList() {
      return {
        addBtn: this.vaildData(this.permission.oem_withdrawal_add, false),
        viewBtn: this.vaildData(this.permission.oem_withdrawal_view, false),
        delBtn: this.vaildData(this.permission.oem_withdrawal_delete, false),
        editBtn: this.vaildData(this.permission.oem_withdrawal_edit, false),
      };
    },
    ids() {
      let ids = [];
      this.selectionList.forEach((ele) => {
        ids.push(ele.id);
      });
      return ids.join(",");
    },
  },
  created(){
  },
  methods: {
    // handleDelete() {},
    beforeOpen(done, type) {
      if (["edit", "view"].includes(type)) {
        // getDetail(this.form.id).then((res) => {
        //   this.form = res.data.data;
        // });
      }
      done();
    },
    // 清空搜索回调方法
    searchReset() {
      this.query = {};
      this.onLoad(this.page);
    },
    // 击搜索后触发该事件(由于page分页信息和search搜索信息是sync修饰符，可以直接通过this.page和this.search拿到)
    searchChange(params, done) {
      // 提现
      if(params.withdrawDateTime){
        params.beginWithdrawDate = params.withdrawDateTime[0];
        params.endWithdrawDate = params.withdrawDateTime[1];
      }
      // 审核
      if(params.adminDateTime){
        params.beginAdminDate = params.adminDateTime[0];
        params.endAdminDate = params.adminDateTime[1];
      }
      
      // 打款
      if(params.notifyDateTime){
        params.beginNotifyDate = params.notifyDateTime[1];
        params.endNotifyDate = params.notifyDateTime[1];
      }
      
      this.query = params;
      this.page.currentPage = 1;
      
      this.onLoad(this.page, params);
      done();
    },
    // 当选择项发生变化时会触发该事件
    selectionChange(list) {
      this.selectionList = list;
    },
    selectionClear() {
      this.selectionList = [];
      this.$refs.crud.toggleSelection();
    },
    // 分页页码改变时会触发
    currentChange(currentPage) {
      this.page.currentPage = currentPage;
    },
    // pageSize改变时会触发 
    sizeChange(pageSize) {
      this.page.pageSize = pageSize;
    },
    // 点击刷新按钮触发该事件(由于page分页信息和search搜索信息是sync修饰符，可以直接通过this.page和this.search拿到)
    refreshChange() {
      this.onLoad(this.page, this.query);
    },
    onLoad(page, params = {}) {
      this.loading = true;
      getList(
        page.currentPage,
        page.pageSize,
        Object.assign(params, this.query, {pageType:'0'})
      ).then((res) => {
        const data = res.data.data;
        this.page.total = data.total;
        this.data = data.records;
        this.loading = false;
        this.selectionClear();
        this.$forceUpdate()
      });
    },
    // 当表格的排序条件发生变化的时候会触发该事件
    sortChange(val) {
      if (val.order == "ascending") {
        //正序
        this.query.ascs = val.prop;
        this.query.descs = "";
      } else {
        //倒序
        this.query.descs = val.prop;
        this.query.ascs = "";
      }
      this.refreshChange();
    },
  },
};
</script>

<style lang="scss" scoped>
.headerFont{
  font-size: 36px;
  margin-bottom: 10px;
  color: #000;
}
.c_card{
  display: flex;
  margin-bottom: 32px;
  .c_card_item{
    margin-right: 16px;
    .c_card_label{
      height: 24px;
      font-size: 16px;
      font-family: Source Han Sans CN-Medium, Source Han Sans CN;
      font-weight: 500;
      line-height: 24px;
      color: #000;
      margin-bottom: 8px;
    }
    .box-card /deep/ .el-card__body{
      width: 288px;
      height: 216px;
      padding: 16px;
      box-sizing: border-box;
      display: flex;
      flex-direction: column;
      justify-content: space-between;
      align-items: center;
      cursor: pointer;
      .b_money{
        margin-top: 16px;
        font-weight: 500;
        color: #000000;
        line-height: 36px;
        font-size: 26px;
        text-align: center;
        
        overflow: hidden;
      }
      .box_box{
        .box_money{
          height: 20px;
          font-size: 14px;
          font-family: Source Han Sans CN-Regular, Source Han Sans CN;
          color: #000000;
          line-height: 20px;
          text-align: center;
        }
        .box_txt{
          height: 20px;
          font-size: 14px;
          font-family: Source Han Sans CN-Regular, Source Han Sans CN;
          color: #000000;
          line-height: 20px;
          margin-top: 10px;
          text-align: center;

          overflow: hidden;
        }
      }
      .b_typeBox{
        height: 50px;
        display: flex;
        align-items: center;
        justify-content: space-between;
        .bt_line{
          width: 1px;
          height: 28px;
          border-left: #000 solid 1px;
        }
        .bt_box{
          width: 128px;
          .bt_money{
            height: 20px;
            font-size: 14px;
            font-family: Source Han Sans CN-Regular, Source Han Sans CN;
            color: #000000;
            line-height: 20px;
            text-align: center;
          }
          .bt_txt{
            height: 20px;
            font-size: 14px;
            font-family: Source Han Sans CN-Regular, Source Han Sans CN;
            color: #000000;
            line-height: 20px;
            text-align: center;
            margin-top: 10px;

            overflow: hidden;
          }

          
        }

      }
      .c_btn2{
        width: 100%;
        display: flex;
        justify-content: space-between;
        .btn{
          width: 120px;
        }
      }
      .c_btn1 .btn{
          width: 256px;
      }
    }
  }
}

.datail{
  padding-left: 141px;
  height: 20px;
  font-size: 14px;
  font-family: Source Han Sans CN-Regular, Source Han Sans CN;
  color: #000000;
  line-height: 20px;
  margin-bottom: 16px;
}

.box_form{
  width: 280px;
  margin: auto;
}
.form_money{
  height: 20px;
  font-size: 14px;
  font-family: Source Han Sans CN-Regular, Source Han Sans CN;
  color: #000000;
  line-height: 20px;
  margin-bottom: 16px;
}
/deep/ .el-form-item__label{
  color: #000;
  font-weight: 500;
}
.el-form--label-top /deep/ .el-form-item__label{
  padding: 0;
}
.takeOutAll{
  height: 20px;
  font-size: 14px;
  font-weight: 500;
  color: #155BD4;
  cursor: pointer;
  text-align: right;
  margin-top: -18px;
}
/deep/ .el-input-number__decrease,/deep/ .el-input-number__increase{
  display: none;
}
.inputNumber /deep/ .el-input__inner{
  padding-left: 15px;
  padding-right: 15px;
  width: 280px;
  text-align: left;
}
</style>
